﻿namespace Sidvall.CodeGenerator
{
	public class DomainObjectRelationField
	{
		#region Business Members

		public DomainObjectProperty SourceProperty { get; private set; }
		public DomainObjectProperty RelatedProperty { get; private set; }

		#region Description

		private string _Description = null;
		public string Description
		{
			get
			{
				if (_Description == null)
					_Description = ToString();
				return _Description;
			}
		}

		#endregion

		#region GetKey

		public static string GetKey(DomainObjectRelationField item)
		{
			if (item == null)
				throw new System.ArgumentNullException("item");

			return item.SourceProperty.Name + "." + item.RelatedProperty.Name;
		}

		#endregion
		#region ToString

		public override string ToString()
		{
			return this.SourceProperty.Name + "-->" + this.RelatedProperty.Name;
		}

		#endregion

		#endregion
		#region Constructors

		public DomainObjectRelationField(DomainObjectProperty sourceProperty, DomainObjectProperty relatedProperty)
		{
			this.SourceProperty = sourceProperty;
			this.RelatedProperty = relatedProperty;
		}

		#endregion
	}
}
